﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SupportingMaterialListFrame.ascx.cs" Inherits="SD.Web.Controls.SupportingMaterialListFrame" %>
<script type="text/javascript">
    function Confirm_Active() {
        return confirm('Do you want active this Supporting Material');
    }
</script>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
                <asp:Panel ID="CurrentListSupportingMaterials" ClientIDMode="Static" runat="server">
                    <div class="titleh">
                        <h3 class="sorting_range">
                            <span>Current List of Supporting Materials </span><span class="right">
                                <asp:LinkButton ID="LinkButtonCreate01" runat="server" CssClass="hg-blue" CommandName="01" CausesValidation="False"
                                oncommand="LinkButtonCreate_Command">H - Create</asp:LinkButton>
                                <asp:LinkButton ID="LinkButtonCreate02" runat="server" CssClass="hg-blue" CommandName="02"  CausesValidation="False"
                                oncommand="LinkButtonCreate_Command">A - Create</asp:LinkButton>
                                <asp:CheckBox ID="CheckBoxInactive" runat="server" Text="Include In-active" AutoPostBack="True"
                                    OnCheckedChanged="CheckBoxInactive_CheckedChanged" />
                            </span>
                        </h3>
                    </div>
                    <asp:GridView ID="GridViewSupportingMaterials" CssClass="tablesorter" runat="server"
                        AutoGenerateColumns="False" AllowPaging="True" PageSize="15" AllowSorting="True"
                        DataSourceID="ObjectDataSourceSupportingMaterial" 
                        onrowcreated="GridViewSupportingMaterials_RowCreated" 
                        onselectedindexchanged="GridViewSupportingMaterials_SelectedIndexChanged" 
                        onselectedindexchanging="GridViewSupportingMaterials_SelectedIndexChanging">
                        <Columns>
                            <asp:TemplateField HeaderText="URL" SortExpression="URL">
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButtonUrl" CausesValidation="false" runat="server" CommandName='<%# Eval("SupportingMaterialId") %>' CommandArgument='<%#Eval("IsActive") %>'
                                       OnClientClick='<%# !(bool)Eval("IsActive") ? "return Confirm_Active();" : string.Empty %>' OnCommand="LinkButtonUrl_Command"><%# Eval("Url") %></asp:LinkButton>
                                </ItemTemplate>
                                <HeaderStyle CssClass="header" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Description" SortExpression="Description">
                                <ItemTemplate>
                                    <%#SD.Commons.StringTools.Substring(Eval("Description"), 0, 45, true)%>
                                </ItemTemplate>
                                <HeaderStyle CssClass="header" />
                            </asp:TemplateField>
                            <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type">
                                <HeaderStyle CssClass="header" />
                                <ItemStyle Width="35px" />
                            </asp:BoundField>
                            <asp:TemplateField HeaderText="Added By" SortExpression="AddedBy">
                                <ItemTemplate>
                                    <%#Eval("User.Account") %>
                                </ItemTemplate>
                                <ItemStyle Width="60px" />
                                <HeaderStyle CssClass="header" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Added Date" SortExpression="AddedDate">
                                <ItemTemplate>
                                    <%#string.Format("{0:dd/MM/yyyy}",Eval("AddedDate"))%>
                                </ItemTemplate>
                                <ItemStyle Width="70px" />
                                <HeaderStyle CssClass="header" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Is Active?" SortExpression="IsActive">
                                <ItemTemplate>
                                    <%#(bool) Eval("IsActive")?"Yes":"No" %>
                                </ItemTemplate>
                                <HeaderStyle CssClass="header" />
                                <ItemStyle Width="50px" />
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                        <blockquote>There are no items to show.</blockquote>
                    </EmptyDataTemplate>
                        <PagerStyle CssClass="pagination_table" />
                    </asp:GridView>
                    
                    <asp:ObjectDataSource ID="ObjectDataSourceSupportingMaterial" runat="server" SelectMethod="GetSupportingMaterial"
                        TypeName="SD.Business.SupportingMaterialBus" OnSelecting="ObjectDataSourceSupportingMaterialSelecting"
                        EnablePaging="true" SelectCountMethod="GetSupportingMaterialCount" StartRowIndexParameterName="startRowIndex"
                        MaximumRowsParameterName="maxRows" SortParameterName="sortType">
                        <SelectParameters>
                            <asp:Parameter Name="filter" Type="Object" ConvertEmptyStringToNull="false" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                </asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>